package org.linphone.util;

import java.util.ArrayList;
import java.util.List;

import org.linphone.Bean.AppInfo;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;

public class AppInfoProvider {
	public static List<AppInfo> getAppInfos(Context context){
		List<AppInfo> appInfos = new ArrayList<AppInfo>();
		PackageManager packageManager = context.getPackageManager();
		List<PackageInfo> installedPackages = packageManager.getInstalledPackages(0);
		AppInfo appinfo = null;
		for(PackageInfo info : installedPackages){
			appinfo = new AppInfo();
			String packageName = info.packageName;
			appinfo.setPackName(packageName);
			String versionName = info.versionName;
			ApplicationInfo applicationInfo = info.applicationInfo;
			Drawable loadIcon = applicationInfo.loadIcon(packageManager);
			String loadLable = applicationInfo.loadLabel(packageManager).toString();
			appinfo.setIcon(loadIcon);
			appinfo.setName(loadLable);
			appinfo.setVersion(versionName);
			if (packageName.equals("com.tencent.qqpimsecure")||
				packageName.equals("com.cleanmaster.security_cn")||
				packageName.equals("com.cleanmaster.mguard_cn")||
				packageName.equals("com.lenovo.safecenter")||
				packageName.equals("cn.opda.a.phonoalbumshoushou")||
				packageName.equals("com.dianxinos.optimizer.duplay")||
				packageName.equals("com.anguanjia.safe")||
				packageName.equals("com.lbe.security")||
				packageName.equals("com.qihoo360.mobilesafe_lite")||
				packageName.equals("com.qihoo360.mobilesafe_mtk6573")||
				packageName.equals("com.qihoo360.mobilesafe_mobilepad")				) {
				appInfos.add(appinfo);
			}
		}
		
		return appInfos;
	}
}
